package registrazione;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.StringTokenizer;
import java.sql.*;


public class Registrazione{
	
	

	public String salvaUtente(String nome, String cognome,  String via, String username, String password, boolean sesso,String [] interessi){
        Connection conn = null;

        try
        {
            String user = "root";
            String pass = "ROOT";
            String url = "jdbc:mysql://localhost/android_db";
            Class.forName ("com.mysql.jdbc.Driver").newInstance ();
            conn = DriverManager.getConnection (url, user, pass);
            return"Database connection established";
        }
        catch (Exception e)
        {
            return "Cannot connect to database server";
        }
        finally
        {
            if (conn != null)
            {
                try
                {
                    conn.close ();
                    System.out.println ("Database connection terminated");
                }
                catch (Exception e) { /* ignore close errors */ }
            }
        }

	}
	
	public void carica(){ 

		FileReader f=null;

		try {
			f = new FileReader("C://utenti.txt");
			BufferedReader in = new BufferedReader(f);  
			String line = in.readLine();
			StringTokenizer st = new StringTokenizer(line);
			while(st.hasMoreTokens() && line !=null){

				line=in.readLine();
			}
			f.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}; 
	}
	
	
	
}
